import {ApplicationContext} from '../ApplicationContext';
import {ClassType} from '../../type';
import {BeanFactory} from '../../beans/factory/BeanFactory';
import {GenericBeanFactory} from '../../beans/factory/GenericBeanFactory';


/**
 * 装饰器实现应用上下文
 * @author Zhang
 * @date 2019/3/16 20:11
 */
export default class DecoratorApplicationContext implements ApplicationContext {
  private readonly beanFactory: BeanFactory;

  constructor() {
    this.beanFactory = new GenericBeanFactory();
  }

  containsBean(name: string): boolean {
    return this.beanFactory.containsBean(name);
  }

  getBean(name: string): any;
  getBean<T>(requiredType: ClassType<T>): T;

  getBean(nameOrClass): any {
    return this.beanFactory.getBean(nameOrClass);
  }


}
